package com.chixing.controller;

import com.chixing.entity.MongDB.Post;
import com.chixing.service.impl.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/posts")
public class PostController {

    @Autowired
    private PostService postService;

    /**
     * 新增主楼
     */
    @PostMapping
    public Post addPost(@RequestBody Post post) {
        return postService.addPost(post);
    }

    /**
     * 获取主楼详情 + 楼中楼
     */
    @GetMapping("/{postId}")
    public Post getPostDetail(@PathVariable String postId) {
        return postService.getPostDetail(postId);
    }

    @GetMapping
    public List<Post> getAllPosts() {
        return postService.getAllPosts();
    }
}
